<?php

    /**
     * @package      Modules
     * @subpackage   Languages_Classes_Widgets
     *
     * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
     */
    class Languages_Classes_Widgets_List extends Widgets_Classes_Widget
    {

    ////////////////////////////////////////////////////////////////////////////
    //                               Attributes                               //
    ////////////////////////////////////////////////////////////////////////////

        /**
         * Widget name
         *
         * @var     string
         */
        protected $_name = 'Languages list';

        /**
         * Widget parameters
         *
         * Format :
         *  KEY =>
         *          type (string, number, boolean)
         *          default
         *
         * @var     array
         */
        protected $_params = array('LIMIT' => array('name'      => 'Max displayed',
                                                    'type'      => self::TYPE_NUMBER,
                                                    'default'   => 5));

    ////////////////////////////////////////////////////////////////////////////
    //                                Methods                                 //
    ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns asked info
         *
         * @param       array       $params
         */
        public function process(array $params = array())
        {
            $languages = Doctrine_Query::create()
                            ->from('DbLanguage l')
                            ->where('l.status = ?', DbBase::ENABLED)
                            ->offset(0)
                            ->limit($params['LIMIT'])
                            ->execute(array(), Doctrine::HYDRATE_ARRAY);

            return $languages;
        }
    }